<?php

/*
|--------------------------------------------------------------------------
| superadmin Routes
|--------------------------------------------------------------------------
|
| Here is where you can register superadmin routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "superadmin" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('auth.login');
});

Route::get('logs', '\Rap2hpoutre\LaravelLogViewer\LogViewerController@index');

// 俱乐部管理员登录
Route::prefix('admin')->group(function () {
    Route::post('login', 'Auth\AdminController@login')->middleware('guest');
});

Auth::routes();

// 首页
Route::get('/home', 'HomeController@index')->name('home')->middleware('auth:superadmin,admin');

// 俱乐部管理员相关路由
Route::group(['middleware' => 'auth:admin'], function () {
    // Route::get('table-list', function () {
    // 	return view('pages.table_list');
    // })->name('table');

    Route::get('clubcheck', 'ClubController@checkList')->name('clubs.check_list');
    Route::patch('clubcheck/{clubscheck}', ['as' => 'clubs.check', 'uses' => 'ClubController@check']);

    // 课程管理
    Route::resource('courses', 'CourseController')->except('show');
    Route::get('courses/{id}/signup-list', 'CourseSignupController@index')->name('course_signup_list');

    // 视频课程管理
    Route::resource('video', 'VideoController');
    Route::patch('video/{id}/status', ['as' => 'video.status', 'uses' => 'VideoController@status']);
});

// 超级管理员相关路由
Route::group(['middleware' => 'auth:superadmin'], function () {
    Route::resource('admins', 'AdminController');    // 管理俱乐部管理员

    Route::resource('clubs', 'ClubController', ['only' => ['index', 'create', 'store', 'show']]);
    Route::patch('clubs/{club}/status', ['as' => 'clubs.status', 'uses' => 'ClubController@status']);

    // 活动管理
    Route::resource('activities', 'ActivityController');
    Route::get('activities/{id}/signup-list', 'ActivitySignupController@index');

    // 比赛管理
    Route::resource('competitions', 'CompetitionController');
    Route::get('competitions/{id}/signup-list', 'CompetitionSignupController@index');

    Route::resource('coach', 'CoachController')->only('index');
    Route::patch('coach/{coach}/rec', ['as' => 'coach.rec', 'uses' => 'CoachController@rec']);
    Route::patch('coach/{coach}/status', ['as' => 'coach.status', 'uses' => 'CoachController@status']);

    Route::resource('post', 'PostController', ['only' => ['index', 'show']]);
    Route::patch('post/{post}/status', ['as' => 'post.status', 'uses' => 'PostController@status']);
    Route::patch('post/{post}/comment/{comment}/status', ['as' => 'post.comment.status', 'uses' => 'PostController@commentStatus']);
});

// 用户资料
Route::group(['middleware' => 'auth'], function () {
    Route::resource('user', 'UserController', ['except' => ['show']]);
    Route::get('profile', ['as' => 'profile.edit', 'uses' => 'ProfileController@edit']);
    Route::put('profile', ['as' => 'profile.update', 'uses' => 'ProfileController@update']);
    Route::put('profile/password', ['as' => 'profile.password', 'uses' => 'ProfileController@password']);
});
